﻿<?xml version="1.0" encoding="utf-8"?>
<xs:schema id="Area"
    elementFormDefault="unqualified" attributeFormDefault="unqualified"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" 
>
  <xs:element name="Area" type="AreaType">
    <xs:key name="NameKey">
      <xs:selector xpath=".
                   |.//Area
                   |.//Part"/>
      <xs:field xpath="@Name"/>
    </xs:key>
    <xs:key name="PropertyNameKey">
      <xs:selector xpath="./Property-List/Property"/>
      <xs:field xpath="@Name"/>
    </xs:key>
  </xs:element>

  <xs:complexType name="AreaType">
    <xs:all>
      <xs:element name="Property-List" type="Property-ListType" minOccurs="0" maxOccurs="1">
      </xs:element>
      <xs:element name="Part-List" type="Part-ListType"  minOccurs="0" maxOccurs="1">
      </xs:element>
      <xs:element name="Area-List" type="Area-ListType"  minOccurs="0" maxOccurs="1">
      </xs:element>
    </xs:all>
    <xs:attribute name="Name" type="NameType" use="required"/>
    <xs:attribute name="Caption" type="xs:string"/>
    <xs:attribute name="IsAsContainer" type="xs:boolean"/>
  </xs:complexType>

  <xs:complexType name="SolidBrushType">
    <xs:attribute name="Color" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"/>
          <xs:pattern value="#[0-9a-fA-F][0-9a-fA-F][0-9a-fA-F]"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="ThicknessType">
    <xs:attribute name="Value" use="required">
      <xs:simpleType>
        <xs:restriction base="xs:string">
          <xs:pattern value="([0-9]*),([0-9]*),([0-9]*),([0-9]*)"/>
        </xs:restriction>
      </xs:simpleType>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="ValueType">
    <xs:attribute name="Value" use="required" type="xs:string">
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="UrlType">
    <xs:attribute name="Url" use="required" type="xs:string">
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="DataSourceType">
    <xs:all>
      <xs:element name="DataSet">
        <xs:complexType>
          <xs:all>
            <xs:element name="DataParameters">
              <xs:complexType>
                <xs:choice maxOccurs="unbounded">
                  <xs:element name="DataParameter">
                    <xs:complexType>
                      <xs:attribute name="Name" use="required" type="xs:string"/>
                      <xs:attribute name="Type" type="xs:string" default="IN"/>
                      <xs:attribute name="Value" use="required" type="xs:string"/>
                    </xs:complexType>
                  </xs:element>
                </xs:choice>
              </xs:complexType>
            </xs:element>
          </xs:all>
          <xs:attribute name="Name" use="required" type="xs:string"/>
        </xs:complexType>
      </xs:element>
    </xs:all>
    <xs:attribute name="Name" use="required" type="xs:string"/>
  </xs:complexType>
  <xs:complexType name="GridColumnsType">
    <xs:choice maxOccurs="unbounded">
      <xs:element name="GridColumn" type="GridColumnType"/>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="GridColumnType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="GridColumn" type="GridColumnType"/>
      <xs:element name="GridColumn.Suffix" type="fixType"/>
      <xs:element name="GridColumn.Prefix" type="fixType"/>
    </xs:choice>
    <xs:attribute name="Name" use="required" type="xs:string"/>
    <xs:attribute name="Caption" use="required" type="xs:string"/>
    <xs:attribute name="DataItemId" type="xs:string"/>
    <xs:attribute name="HAlignment" type="xs:string"/>
    <xs:attribute name="Width" type="xs:integer"/>
  </xs:complexType>
  <xs:complexType name="fixType">
    <xs:choice maxOccurs="unbounded">
      <xs:element name="ConditionImage" type="ConditionImageType"/>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="ConditionImageType">
    <xs:all>
      <xs:element name="ConditionImage.ImageSource">
        <xs:complexType>
          <xs:all>
            <xs:element name="ImageSource" type="UrlType"/>
          </xs:all>
        </xs:complexType>
      </xs:element>
      <xs:element name="ConditionImage.Condtion"/>
    </xs:all>
  </xs:complexType>
  <xs:complexType name="DataRangesType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="DataRange" type="DataRangeType"/>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="DataRangeType">
    <xs:choice minOccurs="0" maxOccurs="unbounded">
      <xs:element name="DataRange.Background">
        <xs:complexType>
          <xs:all>
            <xs:element name="SolidBrush" type="SolidBrushType"/>
          </xs:all>
        </xs:complexType>
      </xs:element>
    </xs:choice>
    <xs:attribute name="StartValue" use="required" type="xs:double"/>
    <xs:attribute name="EndValue" use="required" type="xs:double"/>
  </xs:complexType>
  <xs:complexType name="LinearGradientBrushType">
    <xs:sequence>
      <xs:element maxOccurs="unbounded" name="GradientStop">
        <xs:complexType>
          <xs:attribute name="Color" type="xs:string" use="required" />
          <xs:attribute name="Offset" type="xs:decimal" use="required" />
        </xs:complexType>
      </xs:element>
    </xs:sequence>
    <xs:attribute name="StartPoint" type="xs:string" use="required" />
    <xs:attribute name="EndPoint" type="xs:string" use="required" />
  </xs:complexType>

  <xs:complexType name="Property-ListType">
    <xs:sequence maxOccurs="unbounded">
      <xs:element name="Property" >
        <xs:complexType>
          <xs:all minOccurs="0">
            <xs:element name="Property.Value">
              <xs:complexType>
                <xs:choice minOccurs="1">
                  <xs:element name="SolidBrush" type="SolidBrushType"/>
                  <xs:element name="Thickness" type="ThicknessType"/>
                  <xs:element name="ImageSource" type="UrlType"/>
                  <xs:element name="GridColumns" type="GridColumnsType"/>
                  <xs:element name="DataSource" type="DataSourceType"/>
                  <xs:element name="DataRanges" type="DataRangesType"/>
                  <xs:element name="LinearGradientBrush" type="LinearGradientBrushType"/>
                  <xs:element name="FontFamily">
                    <xs:complexType>
                      <xs:attribute name="Name" use="required" type="xs:string">
                      </xs:attribute>
                      <xs:attribute name="Value" use="required" type="xs:string">
                      </xs:attribute>
                    </xs:complexType>
                  </xs:element>
                  <xs:element name="ColorPlate">
                    <xs:complexType>
                      <xs:choice maxOccurs="unbounded">
                        <xs:element name="SolidBrush" type="SolidBrushType"/>
                      </xs:choice>
                    </xs:complexType>
                  </xs:element>
                </xs:choice>
              </xs:complexType>
            </xs:element>
          </xs:all>
          <xs:attributeGroup ref="PropertyAttr"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:attributeGroup name="PropertyAttr">
    <xs:attribute name="Name" type="xs:string" use="required"/>
    <xs:attribute name="Value"  type="xs:string">
    </xs:attribute>
  </xs:attributeGroup>
  <xs:complexType name="Part-ListType">
    <xs:choice maxOccurs="unbounded">
      <xs:element name="Part" type="PartType" >
        <xs:key name="PartPropertyNameKey">
          <xs:selector xpath="./Property-List/Property"/>
          <xs:field xpath="@Name"/>
        </xs:key>
      </xs:element>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="PartType">
    <xs:all>
      <xs:element name="Property-List" type="Property-ListType"/>
      <xs:element name="ScriptEvent-List" type="ScriptEvent-ListType" minOccurs="0"/>
      <xs:element name="Part-List" type="Part-ListType" minOccurs="0"/>
    </xs:all>
    <xs:attribute name="Name" type="NameType" use="required"></xs:attribute>
    <xs:attribute name="Caption" type="xs:string"></xs:attribute>
    <xs:attribute name="Type" type="xs:string" use="required"></xs:attribute>
  </xs:complexType>
  <xs:complexType name="Area-ListType">
    <xs:choice maxOccurs="unbounded">
      <xs:element name="Area" type="AreaType"/>
      <xs:element name="AreaRef">
        <xs:complexType>
          <xs:attribute name="Name" use="required"/>
          <xs:attribute name="Path" use="required"/>
        </xs:complexType>
      </xs:element>
    </xs:choice>
  </xs:complexType>
  <xs:complexType name="ScriptEvent-ListType">
    <xs:sequence>
      <xs:element name="ScriptEvent">
        <xs:complexType>
          <xs:attribute name="Source">
            <xs:simpleType>
              <xs:restriction base="xs:string">
                <xs:enumeration value="OnDataItemBind"/>
                <xs:enumeration value="OnDataBind"/>
                <xs:enumeration value="OnMouseLeftDown"/>
              </xs:restriction>
            </xs:simpleType>
          </xs:attribute>
          <xs:attribute name="Script" type="xs:string"/>
        </xs:complexType>
      </xs:element>
    </xs:sequence>
  </xs:complexType>
  <xs:simpleType name="NameType">
      <xs:restriction base="xs:string">
        <xs:pattern value="[a-zA-Z_][0-9a-zA-Z_]*"/>
      </xs:restriction>
  </xs:simpleType>
</xs:schema>
